<div class="Item hr">
    <div class="current">广告列表</div>
    <div class="fr"><a href="{:U('add')}" class="btn">添加广告</a></div>
</div>
<form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td>编号</td>
                <td>广告名称</td>
                <td>是否限时</td>
                <td>结束时间</td>
                <td>模板调用代码</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="list" id="myad" empty="$empty">
            <tr align="center">
                <td>{$myad.aid}</td>
                <td>{$myad.adname}</td>
                <td>{$myad['timeset'] == 1 ? '限时标记' : '不限时间'}</td>
                <td>{$myad.endtime|getDateStr}</td>
                <td>&lt;myad tag='{$myad.tagname}' /&gt</td>
                <td> 
                <a href="{:U('edit', array('id' => $myad['aid']))}" class="icon icon-black icon-edit" title="编辑"></a> <a href="javascript:;" class="deleted icon icon-black icon-trash " data-url="{:U('delete')}" data-id="{$myad.aid}" data-title="{$myad.adname}" title="删除"></a>
                </td>
            </tr>
            </volist>
        </tbody>
    </table>
</form>

<div class="page">
    {$page}
</div>
<script type="text/javascript">
$(function(){
    $(".deleted").click(function(){
        var url = $(this).data("url");
        var id = $(this).data("id");
        var name = $(this).data("title");

        popup.confirm("您确定删除 <b>" + name + "</b> ？", '温馨提示',function(action){
            if(action == 'ok'){
                $.ajax({
					'url' : url,
					'dataType' : 'JSON',
					'type' : 'POST',
					'data' : {'id' : id},
					'success' : function(json){
						if (json.status) {
							popup.success(json.info, "删除成功", function(){
								if(json.url){
									window.location.href = json.url;
								}else{
									top.window.location.reload();
								}
							});
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
				});
            }
        });

        return false;
    });
});
</script>
